package com.pine.app.module.security.core.authorize.manager.impl;

import com.pine.app.module.security.core.authorize.manager.RoleAuthorizeManager;

import java.lang.reflect.Method;
import java.util.Set;

/**
 * @author xiaoyuan
 * @create 2020/3/13 14:48
 **/

public class DefaultRoleAuthorizeManagerImpl implements RoleAuthorizeManager {
    @Override
    public void authorize(Set<String> roles, Class<?> target, Method method) {
//        if(!CollectionUtils.isEmpty(roles)){
//            ErrorType.UNAUTHORIZED_CLIENT.throwThis(AuthenticationException::new);
//        }
//        RoleAuthorize classRA =
//                AnnotationUtils.findAnnotation(target, RoleAuthorize.class);
//
//        RoleAuthorize methodRA =
//                AnnotationUtils.findAnnotation(method, RoleAuthorize.class);
//        if(classRA!=null&& classRA.value().length>0){
//            Logical logical = classRA.logical();
//            if(logical==Logical.AND){
//                if(!roles.containsAll(Arrays.asList(classRA.value()))){
//                    ErrorType.UNAUTHORIZED_CLIENT.throwThis(AuthenticationException::new);
//                }
//            }
//            if(logical==Logical.OR){
//                String[] strings = classRA.value();
//
//            }
//
//        }else{
//            if(methodRA!=null&&!roles.contains(methodRA.value())){
//                ErrorType.UNAUTHORIZED_CLIENT.throwThis(AuthenticationException::new);
//            }
//        }

    }
}
